package com.kingdee.eas.lifetime.util;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.border.Border;

@SuppressWarnings("serial")
public class XBangList extends JList {

	public XBangList(Object[] objects) {
		super(objects);
	}

	public static void main(String[] args) {
		JFrame f = new JFrame("test");
		f.setLayout(null);

		XBangList list = new XBangList(new Object[] {"!!!!!"});
		list.setCellRenderer(new ListCellRenderer(){
			JLabel label = new JLabel(){
			
			};
			public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
				label.setBorder(null);
				label.setText(value.toString());
				return label;
			}
		});
		list.setBounds(new Rectangle(20, 20, 200, 400));
		list.setOpaque(false);
		list.setBorder(new Border() {
			public Insets getBorderInsets(Component c) {
				return new Insets(1, 1, 1, 1);
			}

			public boolean isBorderOpaque() {
				return false;
			}

			public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
				g.drawRoundRect(1, 1, width - 2, height - 2, 5, 5);
			}
		});
		f.add(list);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setSize(400, 500);
		f.setVisible(true);
		f.setLocationRelativeTo(null);
	}

}
